package leetcode.dp;

/**
 *
 * 假设有3级台阶
 * 先爬1阶，接下来还有2阶台阶，那问题就是有2阶台阶怎么爬
 * 先爬2阶，接下来还有1阶台阶，那问题就是有1阶台阶怎么爬
 *
 * @author mazouri
 * @create 2021-09-18 0:24
 */
public class _70_climbStairs {
    public int climbStairs(int n) {
        int[] dp = new int[n+1];

        if (n == 1) return 1;
        if (n == 2) return 2;

        dp[1] = 1;
        dp[2] = 2;

        for (int i = 3; i <= n; i++) {
            dp[i] = dp[i-1]+dp[i-2];
        }

        return dp[n];
    }
}
